ostree admin: Fix return value from 'ostree admin [instutil]'
authorOwen W. Taylor <otaylor@fishsoup.net>
Tue, 23 Sep 2014 15:58:27 +0000 (11:58 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Thu, 25 Sep 2014 07:08:06 +0000 (03:08 -0400)
'ostree admin' and 'ostree admin instuil' with no arguments were meant to fail,
but the logic was wrong; add an assertion on the return value from all ostree
commands to catch similar problems in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=737194

src/ostree/ot-admin-builtin-instutil.c
src/ostree/ot-builtin-admin.c
src/ostree/ot-main.c

index 0a6bb315b4c36cf9660a16c6072cfb8bf7f660cf..66ea80edd47c986450cded7b8621be1c77967aa1 100644 (file)
@@ -127,7 +127,13 @@ ot_admin_builtin_instutil (int argc, char **argv, OstreeSysroot *sysroot, GCance
           g_print ("  %s\n", subcommand->name);
           subcommand++;
         }
-      return subcommand_name == NULL ? 1 : 0;
+
+      if (want_help)
+        ret = TRUE;
+      else
+        g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                             "No command specified");
+      goto out;
     }
 
   subcommand = admin_instutil_subcommands;
index f7dce93ac2c46d4f57b5c92c3806248899857261..6db97ca49f83cbb7d2c12baedf9eb4fe53e033d1 100644 (file)
@@ -155,7 +155,13 @@ ostree_builtin_admin (int argc, char **argv, OstreeRepo *repo, GCancellable *can
           g_print ("  %s\n", subcommand->name);
           subcommand++;
         }
-      return subcommand_name == NULL ? 1 : 0;
+
+      if (want_help)
+        ret = TRUE;
+      else
+        g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                             "No command specified");
+      goto out;
     }
 
   subcommand = admin_subcommands;
index 1dfa93d71ab7828349a6c3cecdfec7738a92944e..6adb2d22f1427bd23222b65d7c2ada7154dd0695 100644 (file)
@@ -83,6 +83,7 @@ ostree_run (int    argc,
   const char *repo_arg = NULL;
   gboolean want_help = FALSE;
   gboolean skip;
+  gboolean success = FALSE;
   int in, out, i;
 
   /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */
@@ -191,7 +192,11 @@ ostree_run (int    argc,
 
   if (cmd == NULL)
     {
-      if (!want_help)
+      if (want_help)
+        {
+          success = TRUE;
+        }
+      else
         {
           g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                "No command specified");
@@ -252,7 +257,10 @@ ostree_run (int    argc,
   if (!command->fn (argc, argv, repo, cancellable, &error))
     goto out;
 
+  success = TRUE;
  out:
+  g_assert (success || error);
+
   if (error)
     {
       g_propagate_error (res_error, error);